package com.jtny.nytb.config.dictionary.service.impl;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jtny.component.contants.GenericConstants;
import com.jtny.component.core.util.PageUtils;
import com.jtny.component.core.util.QueryWrapperUtils;
import com.jtny.component.dto.CurrentUserDTO;
import com.jtny.component.entity.LocalHolder;
import com.jtny.component.entity.PageData;
import com.jtny.component.enums.GenericStatusEnum;
import com.jtny.component.exception.ServiceException;
import com.jtny.component.util.Assert;
import com.jtny.component.util.BeanUtils;
import com.jtny.component.util.CurrentUserUtils;
import com.jtny.nytb.config.dictionary.dao.TssoConfigDataDictDao;
import com.jtny.nytb.config.dictionary.dao.TssoConfigDataDictionaryDao;
import com.jtny.nytb.config.dictionary.domain.DictionaryDO;
import com.jtny.nytb.config.dictionary.domain.DictionaryDataDO;
import com.jtny.nytb.config.dictionary.dto.*;
import com.jtny.nytb.config.dictionary.service.DictionaryBiz;
import com.jtny.nytb.config.dictionary.vo.*;
import com.jtny.nytb.config.errorcode.DictionaryErrorCodeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 数据字典业务实现类，具体实现DictionaryBiz定义的接口
 *
 * @author 智慧能源中心-lyq
 * @version 1.0
 * @package com.jtny.nytb.config.dictionary.biz.impl
 * @fileName DictionaryBizImpl.java
 * @createTime 2023年09月01日 10:28
 * @Copyright© 2023 jtny
 * 江投能源技术研究院 版权所有
 */
@Service
public class DictionaryBizImpl implements DictionaryBiz {

    @Autowired
    private TssoConfigDataDictDao dictionaryDAO;

    @Autowired
    private TssoConfigDataDictionaryDao dictionaryDataDAO;

    /**
     * 新增数据字典操作
     *
     * @param firstSaveDictionaryVO 数据字典及字典项VO对象
     * @return 数据字典及字典项VO对象
     * @throws ServiceException 抛出异常
     */
    @Override
    public DictionaryVO saveDictionary(DictionaryInfoFromVO firstSaveDictionaryVO) throws ServiceException {
        //封装DTO对象
        DictionaryDTO dictionaryDTO = BeanUtils.copyToObject(firstSaveDictionaryVO.getDictionaryVO(), DictionaryDTO.class);
        //新建查重对象
        RepeatDictionaryDTO repeatDictionaryDTO = new RepeatDictionaryDTO();
        repeatDictionaryDTO.setDictionaryDTO(dictionaryDTO);
        repeatDictionaryDTO.setIsUpdate(false);
        //如果名称重复 抛出异常
        //数据库操作
        List<DictionaryDTO> dictionaryDTOSName = queryDictionaryByName(repeatDictionaryDTO);
        if (dictionaryDTOSName != null && dictionaryDTOSName.size() > 0) {
            throw new ServiceException(DictionaryErrorCodeEnum.NAME_REPEAT.getErrorCode(), DictionaryErrorCodeEnum.NAME_REPEAT.getErrorMessage());
        }
        //如果编号重复 抛出异常
        //数据库操作
        List<DictionaryDTO> dictionaryDTOSCode = queryDictionaryByCode(repeatDictionaryDTO);
        if (dictionaryDTOSCode != null && dictionaryDTOSCode.size() > 0) {
            throw new ServiceException(DictionaryErrorCodeEnum.CODE_REPEAT.getErrorCode(), DictionaryErrorCodeEnum.CODE_REPEAT.getErrorMessage());
        }
        //获取当前用户
        CurrentUserDTO currentUserDTO = LocalHolder.getCurrentUser();
        dictionaryDTO.setStatus(GenericStatusEnum.NORMAL.getValue());
        CurrentUserUtils.setCreateDefaultField(dictionaryDTO, currentUserDTO);

        //保存数据字典
        //数据库操作
        DictionaryDTO resultDTO = save(dictionaryDTO);
        //如果是首次新增数据字典 且同时新增了数据字典项
        if (firstSaveDictionaryVO.getDictionaryDataVOList() != null && firstSaveDictionaryVO.getDictionaryDataVOList().size() > 0) {
            List<DictionaryDataVO> dictionaryDataVOList = firstSaveDictionaryVO.getDictionaryDataVOList();
            List<DictionaryDataDTO> dictionaryDataDTOList = BeanUtils.copyToList(dictionaryDataVOList, DictionaryDataDTO.class);
            //都设置 基本信息 设置完保存的数据库
            for (DictionaryDataDTO dictionaryDataDTO : dictionaryDataDTOList) {
                CurrentUserUtils.setCreateDefaultField(dictionaryDataDTO, currentUserDTO);
                dictionaryDataDTO.setStatus(GenericStatusEnum.NORMAL.getValue());
                //数据字典项的字典id 设置为保存的数据字典id
                dictionaryDataDTO.setDictId(resultDTO.getId());
            }
            // dictionaryData数据库操作
            saveBatch(dictionaryDataDTOList);
        }
        //将数据字典DTO对象转化为VO对象，并返回
        return BeanUtils.copyToObject(resultDTO, DictionaryVO.class);
    }

    /**
     * 保存批处理字典
     *
     * @param dictionaryInfoList 首先保存词典
     * @return {@link Boolean}
     * @throws ServiceException 服务异常
     */
    @Override
    public Boolean saveBatchDictionary(List<DictionaryInfoDTO> dictionaryInfoList) throws ServiceException {
        //数据库操作
        return saveAndBatchDictionary(dictionaryInfoList);
    }

    /**
     * 查询数据字典操作
     *
     * @param id 数据字典ID
     * @return 数据字典VO对象
     * @throws ServiceException 抛出异常
     */
    @Override
    public DictionaryMessageVO detailDictionary(Long id) throws ServiceException {
        //通过数据字典id获取数据字典DTO对象
        //数据库操作
        DictionaryDTO dictionaryDTO = getById(id);
        if (dictionaryDTO == null) {
            return null;
        } else {
            //查询对应的数据字典项列表
            //dictionaryData数据库操作
            List<DictionaryDataDTO> byDictionaryIds = getByDictionaryId(dictionaryDTO.getId());
            //封装数据字典项信息VO对象，并返回
            List<DictionaryDataVO> dictionaryDataVOS = BeanUtils.copyToList(byDictionaryIds, DictionaryDataVO.class);
            //封装数据字典信息VO对象，并返回
            DictionaryVO dictionaryVO = BeanUtils.copyToObject(dictionaryDTO, DictionaryVO.class);
            //返回数据
            DictionaryMessageVO dictionaryMessageVO = new DictionaryMessageVO();
            dictionaryMessageVO.setDictionaryVO(dictionaryVO);
            dictionaryMessageVO.setDictionaryDataVO(dictionaryDataVOS);
            return dictionaryMessageVO;
        }
    }

    /**
     * 更新数据字典操作
     *
     * @param dictionaryVO 数据字典VO对象
     * @throws ServiceException 抛出异常
     */
    @Override
    public void updateDictionary(DictionaryVO dictionaryVO) throws ServiceException {
        Long dictionaryVOId = dictionaryVO.getId();
        if (dictionaryVOId == null) {
            throw new ServiceException(DictionaryErrorCodeEnum.PARAM_DICTIONARY_ID_IS_NULL.getErrorCode(), DictionaryErrorCodeEnum.PARAM_DICTIONARY_ID_IS_NULL.getErrorMessage());
        }
        //通过数据字典id获取数据字典DTO对象
        //数据库操作
        DictionaryDTO dictionaryDTO = getById(dictionaryVOId);
        if (dictionaryDTO == null) {
            throw new ServiceException(DictionaryErrorCodeEnum.PARAM_OBJECT_IS_NULL.getErrorCode(), DictionaryErrorCodeEnum.PARAM_OBJECT_IS_NULL.getErrorMessage());
        }
        //获取当前登录用户
        CurrentUserDTO currentUserDTO = LocalHolder.getCurrentUser();
        //封装待修改的数据字典DTO对象
        BeanUtils.copyObject(dictionaryVO, dictionaryDTO);
        CurrentUserUtils.setUpdateDefaultField(dictionaryDTO, currentUserDTO);
        //新建查重对象
        RepeatDictionaryDTO repeatDictionaryDTO = new RepeatDictionaryDTO();
        repeatDictionaryDTO.setDictionaryDTO(dictionaryDTO);
        repeatDictionaryDTO.setIsUpdate(true);
        //如果已存在 要更新的名称 则抛出异常
        //数据库操作
        List<DictionaryDTO> dictionaryDTOSName = queryDictionaryByName(repeatDictionaryDTO);
        if (dictionaryDTOSName != null && dictionaryDTOSName.size() > 0) {
            throw new ServiceException(DictionaryErrorCodeEnum.NAME_REPEAT.getErrorCode(), DictionaryErrorCodeEnum.NAME_REPEAT.getErrorMessage());
        }
        //如果已存在要更新的编号 则抛出异常
        //数据库操作
        List<DictionaryDTO> dictionaryDTOSCode = queryDictionaryByCode(repeatDictionaryDTO);
        if (dictionaryDTOSCode != null && dictionaryDTOSCode.size() > 0) {
            throw new ServiceException(DictionaryErrorCodeEnum.CODE_REPEAT.getErrorCode(), DictionaryErrorCodeEnum.CODE_REPEAT.getErrorMessage());
        }
        //修改操作
        //数据库操作
        update(dictionaryDTO);
    }

    /**
     * 分页查询数据字典操作
     *
     * @param dictionaryPageQueryParamVO 查询条件VO参数对象
     * @return pageDate对象
     * @throws ServiceException 抛出异常
     */
    @Override
    public PageData<DictionaryVO> queryPage(DictionaryPageQueryParamVO dictionaryPageQueryParamVO) throws ServiceException {
        //新建返回对象
        DictionaryPageVO dictionaryPageVO = new DictionaryPageVO();
        //检验参数处理
        if (dictionaryPageQueryParamVO == null) {
            dictionaryPageQueryParamVO = new DictionaryPageQueryParamVO();
            dictionaryPageQueryParamVO.setPageNo(GenericConstants.DEFAULT_PAGE_NO);
            dictionaryPageQueryParamVO.setPageSize(GenericConstants.DEFAULT_PAGE_SIZE);
        }
        //分页查询数据字典信息
        DictionaryPageQueryDTO dictionaryPageQueryDTO = BeanUtils.copyToObject(dictionaryPageQueryParamVO, DictionaryPageQueryDTO.class);
        //数据库操作
        PageData<DictionaryDTO> pageDataForDTO = queryPage(dictionaryPageQueryDTO);
        if (pageDataForDTO == null || CollUtil.isEmpty(pageDataForDTO.getData())) {
            return new PageData<>();
        }
        Collection<DictionaryDTO> dictionaryDTOCollection = pageDataForDTO.getData();
        ArrayList<DictionaryVO> dictionaryVOList = new ArrayList<>(dictionaryDTOCollection.size());
        dictionaryDTOCollection.forEach(
                dictionaryDTO -> {
                    DictionaryVO dictionaryVO = BeanUtils.copyToObject(dictionaryDTO, DictionaryVO.class);
                    dictionaryVOList.add(dictionaryVO);
                }
        );
        PageData<DictionaryVO> pageDataForVO = pageDataForDTO.transformExcludeData(DictionaryVO.class);
        pageDataForVO.setData(dictionaryVOList);

        return pageDataForVO;
    }

    /**
     * 删除数据字典操作
     *
     * @param id 数据字典Id
     * @throws ServiceException 抛出异常
     */
    @Override
    public void deleteDictionary(Long id) throws ServiceException {
        //通过数据字典id获取产品DTO对象
        //数据库操作
        DictionaryDTO dictionaryDTO = getById(id);
        if (dictionaryDTO == null) {
            throw new ServiceException(DictionaryErrorCodeEnum.PARAM_NOT_FIND.getErrorCode(), DictionaryErrorCodeEnum.PARAM_NOT_FIND.getErrorMessage());
        }
        //获取当前登录用户
        CurrentUserDTO currentUserDTO = LocalHolder.getCurrentUser();
        //封装待修改的数据字典DTO对象
        dictionaryDTO.setStatus(GenericStatusEnum.DELETED.getValue());
        CurrentUserUtils.setUpdateDefaultField(dictionaryDTO, currentUserDTO);
        //修改操作
        //数据库操作
        update(dictionaryDTO);
    }

    /**
     * 禁用数据字典
     *
     * @param id 数据字典Id
     * @throws ServiceException 抛出异常
     */
    @Override
    public void disableDictionary(Long id) throws ServiceException {

        //通过数据字典id获取数据字典DTO对象
        //数据库操作
        DictionaryDTO dictionaryDTO = getById(id);
        if (dictionaryDTO == null) {
            throw new ServiceException(DictionaryErrorCodeEnum.PARAM_OBJECT_IS_NULL.getErrorCode(), DictionaryErrorCodeEnum.PARAM_OBJECT_IS_NULL.getErrorMessage());
        }

        //获取当前登录用户
        CurrentUserDTO currentUserDTO = LocalHolder.getCurrentUser();
        //封装待修改的数据字典DTO对象
        dictionaryDTO.setStatus(GenericStatusEnum.DISABLE.getValue());
        CurrentUserUtils.setUpdateDefaultField(dictionaryDTO, currentUserDTO);

        //修改操作
        //数据库操作
        update(dictionaryDTO);
    }

    /**
     * 启用数据字典
     *
     * @param dictionaryId 数据字典Id
     * @throws ServiceException 抛出异常
     */
    @Override
    public void enableDictionary(Long dictionaryId) throws ServiceException {
        ///通过数据字典id获取数据字典DTO对象
        //数据库操作
        DictionaryDTO dictionaryDTO = getById(dictionaryId);
        if (dictionaryDTO == null) {
            throw new ServiceException(DictionaryErrorCodeEnum.PARAM_OBJECT_IS_NULL.getErrorCode(), DictionaryErrorCodeEnum.PARAM_OBJECT_IS_NULL.getErrorMessage());
        }

        //获取当前登录用户
        CurrentUserDTO currentUserDTO = LocalHolder.getCurrentUser();
        //封装待修改的数据字典DTO对象
        dictionaryDTO.setStatus(GenericStatusEnum.NORMAL.getValue());
        CurrentUserUtils.setUpdateDefaultField(dictionaryDTO, currentUserDTO);

        //修改操作
        //数据库操作
        update(dictionaryDTO);
    }

    /**
     * 根据数据字典名称查询数据字典项信息
     *
     * @param name 数据字典名称
     * @return 数据字典项信息
     */
    @Override
    public List<DictionaryDataVO> queryDictionaryByName(String name) throws ServiceException {
        //数据库操作
        List<DictionaryDataDTO> dictionaryList = listDictionaryByName(name);
        return BeanUtils.copyToList(dictionaryList, DictionaryDataVO.class);
    }

    @Override
    public List<DictionaryDataVO> queryDictionaryByNameCode(String code) {
        //数据库操作
        List<DictionaryDataDTO> dictionaryList = listDictionaryByNameCode(code);
        return BeanUtils.copyToList(dictionaryList, DictionaryDataVO.class);
    }

    /**
     * 按名称存在字典
     *
     * @param nameList 名称列表
     * @return {@link List}<{@link String}>
     */
    @Override
    public List<String> existDictionaryByName(List<String> nameList) {
        if (CollUtil.isNotEmpty(nameList)) {
            //数据库操作
            return existAndDictionaryByName(nameList);
        }
        return CollUtil.newArrayList();
    }


///////////////////////////////////////////
    public DictionaryDTO save(DictionaryDTO dictionaryDTO) throws ServiceException {

        // 将DTO对象的属性复制给DO对象
        DictionaryDO dictionaryDO = BeanUtils.copyToObject(dictionaryDTO, DictionaryDO.class);
        // 保存操作
        dictionaryDAO.insert(dictionaryDO);
        // 将id设置给DTO对象
        dictionaryDTO.setId(dictionaryDO.getId());

        return dictionaryDTO;
    }


    public void update(DictionaryDTO dictionaryDTO) throws ServiceException {

        // 将DTO对象的属性复制给DO对象
        DictionaryDO dictionaryDO = BeanUtils.copyToObject(dictionaryDTO, DictionaryDO.class);
        // 修改操作
        dictionaryDAO.updateById(dictionaryDO);
    }


    public DictionaryDTO getById(Long id) {
        // 通过主键id查询DO对象
        DictionaryDO dictionaryDO = dictionaryDAO.selectById(id);
        return BeanUtils.copyToObject(dictionaryDO, DictionaryDTO.class);
    }


    public PageData<DictionaryDTO> queryPage(DictionaryPageQueryDTO dictionaryPageQueryDTO) {
        // 封装查询条件QueryWrapper对象
        QueryWrapper<DictionaryDO> queryWrapper = QueryWrapperUtils.getQueryWrapper(dictionaryPageQueryDTO);
        queryWrapper.orderByDesc("id");
        queryWrapper.ne("status", GenericStatusEnum.DELETED.getValue());
        // 分页查询数据字典信息
        Page<DictionaryDO> page = Page.of(dictionaryPageQueryDTO.getPageNo(), dictionaryPageQueryDTO.getPageSize());
        PageData<DictionaryDO> pageDataForDO = PageUtils.getPageData(dictionaryDAO.selectPage(page, queryWrapper), dictionaryPageQueryDTO);

        return pageDataForDO.transformData(DictionaryDTO.class);
    }


    public List<DictionaryDTO> queryDictionaryByName(RepeatDictionaryDTO repeatDictionaryDTO) {
        //封装查询条件QueryWrapper对象
        QueryWrapper<DictionaryDO> wrapper = new QueryWrapper<>();
        //设置查询条件
        wrapper.eq("name", repeatDictionaryDTO.getDictionaryDTO().getName());
        wrapper.ne("status",GenericStatusEnum.DELETED.getValue());
        //如果是更新 则去重
        if(repeatDictionaryDTO.getIsUpdate()){
            wrapper.ne("id", repeatDictionaryDTO.getDictionaryDTO().getId());
        }
        List<DictionaryDO> dictionaryDOS = dictionaryDAO.selectList(wrapper);
        if(dictionaryDOS != null && dictionaryDOS.size() > 0){
            return BeanUtils.copyToList(dictionaryDOS, DictionaryDTO.class);
        }else {
            return null;
        }
    }


    public List<DictionaryDTO> queryDictionaryByCode(RepeatDictionaryDTO repeatDictionaryDTO) {
        //封装查询条件QueryWrapper对象
        QueryWrapper<DictionaryDO> wrapper = new QueryWrapper<>();
        //设置查询条件
        wrapper.eq("code", repeatDictionaryDTO.getDictionaryDTO().getCode());
        wrapper.ne("status", GenericStatusEnum.DELETED.getValue());
        //如果是更新 则去重
        if(repeatDictionaryDTO.getIsUpdate()){
            wrapper.ne("id", repeatDictionaryDTO.getDictionaryDTO().getId());
        }
        List<DictionaryDO> dictionaryDOS = dictionaryDAO.selectList(wrapper);
        if(dictionaryDOS != null && dictionaryDOS.size() > 0){
            return BeanUtils.copyToList(dictionaryDOS, DictionaryDTO.class);
        }else {
            return null;
        }
    }


    public DictionaryDTO selectDictionaryByName(String name) {
        //封装查询条件QueryWrapper对象
        QueryWrapper<DictionaryDO> wrapper = new QueryWrapper<>();
        //设置查询条件
        wrapper.eq("name", name);
        DictionaryDO dictionaryDO = dictionaryDAO.selectOne(wrapper);
        if(dictionaryDO != null){
            return BeanUtils.copyToObject(dictionaryDO, DictionaryDTO.class);
        }else {
            return null;
        }
    }

    private DictionaryDTO selectDictionaryByCode(String code) {
        //封装查询条件QueryWrapper对象
        QueryWrapper<DictionaryDO> wrapper = new QueryWrapper<>();
        //设置查询条件
        wrapper.eq("code", code);
        DictionaryDO dictionaryDO = dictionaryDAO.selectOne(wrapper);
        if(dictionaryDO != null){
            return BeanUtils.copyToObject(dictionaryDO, DictionaryDTO.class);
        }else {
            return null;
        }
    }

    /**
     * 删除数据字典信息
     *
     * @param name 数据字典名称
     * @throws ServiceException 抛出异常
     */

    @Override
    public List<DictionaryDataDTO> listDictionaryByName(String name) {
        DictionaryDTO dictionaryDTO = selectDictionaryByName(name);
        Assert.notNull(dictionaryDTO, DictionaryErrorCodeEnum.PARAM_NOT_FIND);
        Long dictionaryId = dictionaryDTO.getId();
        QueryWrapper<DictionaryDataDO> wrapper = new QueryWrapper<>();
        wrapper.eq("dict_id", dictionaryId);
        wrapper.ne("status", GenericStatusEnum.DELETED.getValue());
        List<DictionaryDataDO> dictionaryDataDOS = dictionaryDataDAO.selectList(wrapper);
        return BeanUtils.copyToList(dictionaryDataDOS, DictionaryDataDTO.class);
    }


    public List<DictionaryDataDTO> listDictionaryByNameCode(String code) {
        DictionaryDTO dictionaryDTO = selectDictionaryByCode(code);
        Assert.notNull(dictionaryDTO, DictionaryErrorCodeEnum.PARAM_NOT_FIND);
        Long dictionaryId = dictionaryDTO.getId();
        QueryWrapper<DictionaryDataDO> wrapper = new QueryWrapper<>();
        wrapper.eq("dict_id", dictionaryId);
        wrapper.ne("status", GenericStatusEnum.DELETED.getValue());
        List<DictionaryDataDO> dictionaryDataDOS = dictionaryDataDAO.selectList(wrapper);
        return BeanUtils.copyToList(dictionaryDataDOS, DictionaryDataDTO.class);
    }

    /**
     * 按名称存在字典
     *
     * @param nameList 名称列表
     * @return {@link List}<{@link String}>
     */

    public List<String> existAndDictionaryByName(List<String> nameList) {
        if(CollUtil.isNotEmpty(nameList)){
            LambdaQueryWrapper<DictionaryDO> wrapper = Wrappers.<DictionaryDO>lambdaQuery()
                    .in(DictionaryDO::getName, nameList)
                    .ne(DictionaryDO::getStatus, GenericStatusEnum.DELETED.getValue());
            List<DictionaryDO> dictionaryList = dictionaryDAO.selectList(wrapper);
            return dictionaryList.stream().map(DictionaryDO::getName).collect(Collectors.toList());
        }
        return CollUtil.newArrayList();
    }

    /**
     * 保存批处理字典
     *
     * @param dictionaryInfoList 词典信息列表
     * @return {@link Boolean}
     */

    public Boolean saveAndBatchDictionary(List<DictionaryInfoDTO> dictionaryInfoList) {
        for (DictionaryInfoDTO dictionaryInfoDTO : dictionaryInfoList) {
            DictionaryDTO save = save(dictionaryInfoDTO.getDictionary());
            Long id = save.getId();
            if(CollUtil.isNotEmpty(dictionaryInfoDTO.getDictionaryDataList())){
                List<DictionaryDataDO> collect = dictionaryInfoDTO.getDictionaryDataList().stream().map(item -> {
                    DictionaryDataDO dictionaryDataDO = BeanUtils.copyToObject(item, DictionaryDataDO.class);
                    dictionaryDataDO.setDictId(id);
                    return dictionaryDataDO;
                }).collect(Collectors.toList());
                dictionaryDataDAO.insertBatch(collect);
            }
        }
        return Boolean.TRUE;
    }
    public int saveBatch(List<DictionaryDataDTO> list) throws ServiceException {
        //DTO对象转DO对象
        List<DictionaryDataDO> dictionaryDataDOS = BeanUtils.copyToList(list, DictionaryDataDO.class);
        //批量插入并且返回
        return dictionaryDataDAO.insertBatch(dictionaryDataDOS);
    }
    public List<DictionaryDataDTO> getByDictionaryId(Long dictionaryId) {
        QueryWrapper<DictionaryDataDO> wrapper = new QueryWrapper<>();
        wrapper.eq("dict_id", dictionaryId);
        wrapper.ne("status", 9);
        List<DictionaryDataDO> dictionaryDataDOS = dictionaryDataDAO.selectList(wrapper);
        if (dictionaryDataDOS != null) {
            return BeanUtils.copyToList(dictionaryDataDOS, DictionaryDataDTO.class);
        } else {
            return null;
        }
    }
}
